package com.xy.annotaion.handler.kotlin.compiler.demo1

import java.util.*

open class ASTList(list: List<ASTree>) : ASTree() {

    protected val children = list


    override fun location(): String? {
        for (t in children) {
            val s = t.location()
            if (Objects.nonNull(s)) {
                return s
            }
        }
        return null
    }

    override fun child(i: Int) = children[i]

    override fun numChildren() = children.size

    override fun children() = children.iterator()

    override fun toString(): String {
        val builder = StringBuilder()
        builder.append("(");
        var sep = ""
        for (t in children) {
            builder.append(sep)
            sep = " "
            builder.append(t.toString())
        }
        return builder.append(")").toString()
    }
}
